{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## tensorflow 经典方法学习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 引入 必要包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\progrom\\python\\python\\python3\\lib\\site-packages\\h5py\\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### tf.nn.embedding_lookup函数的用法\n",
    "\n",
    "tf.nn.embedding_lookup函数的用法主要是选取一个张量里面索引对应的元素。tf.nn.embedding_lookup（tensor, id）:tensor就是输入张量，id就是张量对应的索引，其他的参数不介绍。\n",
    "\n",
    "参考网址： [tf.nn.embedding_lookup函数的用法](https://blog.csdn.net/uestc_c2_403/article/details/72779417)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.96171387]\n",
      " [0.96199781]]\n",
      "[[0.77322859]\n",
      " [0.96171387]\n",
      " [0.71319904]\n",
      " [0.96199781]\n",
      " [0.46039099]\n",
      " [0.42424624]\n",
      " [0.48325266]\n",
      " [0.92541773]\n",
      " [0.10654726]\n",
      " [0.93055393]]\n"
     ]
    }
   ],
   "source": [
    "c = np.random.random([10,1])\n",
    "b = tf.nn.embedding_lookup(c, [1, 3])\n",
    "\n",
    "import tensorflow as tf;\n",
    "import numpy as np;\n",
    " \n",
    "c = np.random.random([10,1])\n",
    "b = tf.nn.embedding_lookup(c, [1, 3])\n",
    " \n",
    "with tf.Session() as sess:\n",
    "    sess.run(tf.initialize_all_variables())\n",
    "    print(sess.run(b))\n",
    "    print(c)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 【TensorFlow】tf.concat的用法\n",
    "\n",
    "tf.concat(concat_dim, values, name='concat')\n",
    "除去name参数用以指定该操作的name，与方法有关的一共两个参数：\n",
    "\n",
    "<b>第一个参数concat_dim</b>：必须是一个数，表明在哪一维上连接\n",
    "\n",
    "1、如果concat_dim是0，那么在某一个shape的第一个维度上连，对应到实际，就是叠放到列上\n",
    "\n",
    "```   \n",
    "    t1 = [[1, 2, 3], [4, 5, 6]]\n",
    "    t2 = [[7, 8, 9], [10, 11, 12]]\n",
    "    tf.concat(0, [t1, t2]) == > [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]\n",
    "```\n",
    "\n",
    "2、 如果concat_dim是1，那么在某一个shape的第二个维度上连\n",
    "\n",
    "```\n",
    "    t1 = [[1, 2, 3], [4, 5, 6]]\n",
    "    t2 = [[7, 8, 9], [10, 11, 12]]\n",
    "    tf.concat(1, [t1, t2]) ==> [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12\n",
    "```\n",
    "\n",
    "<b>第二个参数values</b>：就是两个或者一组待连接的tensor了\n",
    "\n",
    "参考网址： [【TensorFlow】tf.concat的用法](https://blog.csdn.net/mao_xiao_feng/article/details/53366163)\n",
    "\n",
    "### 【TensorFlow】用expand_dim()来增加维度\n",
    "\n",
    "TensorFlow中，想要维度增加一维，可以使用tf.expand_dims(input, dim, name=None)函数。\n",
    "\n",
    "<b>Args</b>: \n",
    "input: A Tensor. \n",
    "dim: A Tensor. Must be one of the following types: int32, int64. 0-D (scalar). Specifies the dimension index at which to expand the shape of input. \n",
    "name: A name for the operation (optional).\n",
    "\n",
    "<b>Returns</b>: \n",
    "A Tensor. Has the same type as input. Contains the same data as input, but its shape has an additional dimension of size 1 added.\n",
    "\n",
    "参考网址： [TensorFlow用expand_dim()来增加维度](https://blog.csdn.net/jasonzzj/article/details/60811035)\n",
    "\n",
    "### 【TensorFlow】tf.nn.conv2d()使用\n",
    "\n",
    "```\n",
    "    conv2d(\n",
    "        input,\n",
    "        filter,\n",
    "        strides,\n",
    "        padding,\n",
    "        use_cudnn_on_gpu=None,\n",
    "        data_format=None,\n",
    "        name=None\n",
    "    )\n",
    "```\n",
    "1. input是一个4d输入[batch_size, in_height, in_width, n_channels]，表示图片的批数，大小和通道。\n",
    "1. filter是一个4d输入[filter_height, filter_width, in_channels, out_channels]，表示kernel的大小，输入通道数和输出通道数，其中输出通道数表示从上一层提取多少特征。\n",
    "1. strides是一个1d输入，长度为4，其中stride[0]和stride[3]必须为1，一般格式为[1, stride[1], stride[2], 1]，在大部分情况下，因为在height和width上的步进设为一样，因此通常为[1, stride, stride, 1]。 \n",
    "1. padding是一个字符串输入，分为SAME和VALID分别表示是否需要填充，因为卷积完之后因为周围的像素没有卷积到，因此一般是会出现卷积完的输出尺寸小于输入的现象的\n",
    "\n",
    "参考网址： \n",
    "1. [tf.nn.conv2d()使用](https://blog.csdn.net/loseinvain/article/details/78935192)\n",
    "1. [TensorFlow tf.nn.conv2d()介绍](https://blog.csdn.net/guoyunfei20/article/details/78413365)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------sess.run(inputs_forward)----------\n",
      "[[[8.96570443e-01 8.31685654e-02 7.46792569e-01 1.06018532e-01\n",
      "   7.26397135e-01 5.44089672e-01 4.82173516e-01 9.33843741e-03\n",
      "   2.89801706e-01 4.10119423e-02 9.58390149e-01 4.12560511e-01\n",
      "   8.83796577e-01 1.10268567e-01 9.19881510e-01 5.78728472e-01\n",
      "   5.25630857e-01 5.28832557e-01 5.56670677e-02 1.57373812e-01]\n",
      "  [1.04018237e-01 4.81320467e-01 5.27650978e-01 8.57054512e-01\n",
      "   7.40748740e-01 1.09338858e-01 1.00325901e-01 1.89790440e-01\n",
      "   7.61290041e-02 3.29477112e-01 4.92564692e-01 2.09466067e-01\n",
      "   6.62136143e-01 4.56833630e-01 1.13651210e-01 7.64574761e-01\n",
      "   8.75553815e-01 2.57104266e-01 3.82199989e-01 8.88400448e-01]\n",
      "  [1.92234324e-01 7.31839752e-01 8.13085637e-01 7.11293615e-01\n",
      "   9.63730778e-01 3.37759737e-01 3.34531565e-01 8.47761540e-01\n",
      "   7.74562021e-02 9.49451964e-01 9.75115905e-01 4.89986068e-01\n",
      "   5.10260496e-01 9.94694069e-01 9.91884385e-01 2.85520317e-01\n",
      "   5.39394544e-01 4.71611336e-01 3.33974081e-01 7.89076839e-01]\n",
      "  [9.92979005e-01 2.23866418e-01 6.88886401e-01 7.62047446e-02\n",
      "   6.24134621e-01 5.72434206e-01 4.08975609e-01 8.86981111e-01\n",
      "   4.21420820e-01 5.99470812e-01 9.09434138e-01 2.78553699e-01\n",
      "   8.17077950e-01 3.41340429e-01 8.01799717e-02 7.70933951e-01\n",
      "   9.07635665e-01 3.08314716e-01 7.67134006e-01 7.50601895e-01]\n",
      "  [1.18920709e-01 9.88059619e-01 5.51403647e-03 6.17685735e-01\n",
      "   1.65720283e-02 5.83843144e-02 1.09345813e-01 7.65406390e-01\n",
      "   3.74953736e-01 6.57179654e-02 7.06696250e-01 7.68788786e-01\n",
      "   4.46079472e-01 2.39773861e-02 1.14741026e-01 8.85640234e-01\n",
      "   9.91610060e-03 9.89951930e-01 3.87319706e-01 1.28302197e-01]\n",
      "  [8.35932124e-01 6.35716879e-01 5.66622421e-01 8.60308973e-01\n",
      "   5.16702776e-01 4.05175870e-01 9.75087201e-01 7.53946624e-01\n",
      "   9.49298331e-01 3.32521487e-01 4.98948663e-01 8.31487158e-01\n",
      "   4.14593596e-01 1.08733767e-01 2.95207571e-01 9.63365097e-02\n",
      "   2.72041965e-01 6.22715275e-01 9.63453870e-01 3.66451172e-01]\n",
      "  [2.67779693e-01 5.51881383e-01 8.85975484e-01 4.39197304e-01\n",
      "   2.57868009e-01 4.11354695e-01 4.27747253e-01 8.62450368e-01\n",
      "   8.28166561e-01 7.46302547e-01 7.31208542e-01 8.64110317e-01\n",
      "   8.72511380e-01 1.46454656e-02 4.91870336e-01 1.63528125e-01\n",
      "   3.72650009e-01 1.73566381e-01 9.21460167e-01 9.94657651e-01]\n",
      "  [2.57861380e-01 5.43326738e-01 6.89418629e-01 7.44949203e-01\n",
      "   5.42144541e-01 6.08387495e-01 5.95257190e-01 1.22885651e-01\n",
      "   2.92909080e-01 1.93816983e-01 7.33291372e-01 7.31500145e-01\n",
      "   7.18013584e-01 8.10905816e-01 2.69346513e-01 8.22111453e-01\n",
      "   6.45305416e-01 3.31678287e-01 6.96160345e-01 8.91131992e-02]\n",
      "  [4.43284883e-02 3.34382665e-01 2.06058600e-01 6.40575751e-01\n",
      "   6.79700316e-02 6.89954568e-01 8.38905885e-01 7.69455040e-01\n",
      "   9.71017231e-01 1.08514020e-01 5.12066373e-01 2.59718081e-01\n",
      "   9.47327429e-01 1.38100149e-01 9.35850832e-01 6.75602921e-01\n",
      "   6.02855279e-01 5.16098812e-01 4.64939584e-02 6.22011336e-01]\n",
      "  [4.44682505e-01 5.47630472e-02 3.23345770e-01 5.96809590e-01\n",
      "   8.69848168e-01 4.14159401e-01 3.70017108e-01 7.49865543e-01\n",
      "   9.17816042e-02 1.66046823e-01 1.08873964e-01 1.75414634e-01\n",
      "   1.56186630e-04 9.73711966e-01 8.56180380e-01 4.83140157e-01\n",
      "   8.77924317e-01 7.53049506e-01 3.18696673e-01 9.22830423e-01]]\n",
      "\n",
      " [[6.02039320e-01 8.00459053e-01 1.04356367e-02 3.67586269e-01\n",
      "   7.93983414e-01 3.62995571e-01 5.54600497e-01 6.12719262e-01\n",
      "   2.49250606e-01 2.83536497e-01 4.13200337e-01 2.20946455e-02\n",
      "   4.91585011e-01 1.04059637e-01 3.55707488e-01 4.99207265e-03\n",
      "   6.70262147e-01 1.04029765e-01 4.72175832e-01 6.86416769e-01]\n",
      "  [1.62471963e-01 4.16144358e-01 6.14523028e-01 5.30361593e-01\n",
      "   3.83633433e-01 2.35939683e-01 7.65269774e-01 7.35012759e-01\n",
      "   2.05205186e-01 8.63208518e-01 4.89419879e-01 8.49441045e-01\n",
      "   5.42232207e-01 2.09617611e-01 2.73755203e-01 6.77926415e-02\n",
      "   2.08748311e-01 8.01157477e-01 4.48007974e-01 7.38134862e-01]\n",
      "  [7.43420553e-01 4.76821548e-01 8.16741808e-02 3.71219574e-01\n",
      "   9.68247719e-01 3.78425942e-01 2.42003800e-01 7.39626767e-02\n",
      "   3.15392027e-01 8.95682986e-01 8.55052238e-01 6.76803505e-01\n",
      "   6.51611320e-01 1.93265171e-03 3.11154828e-01 9.81952709e-01\n",
      "   1.80506428e-01 1.24686513e-02 8.41099856e-01 4.62571756e-01]\n",
      "  [2.08419546e-01 8.57595901e-01 3.90342420e-01 7.37980996e-01\n",
      "   5.87401973e-01 6.67498089e-01 8.77394254e-01 9.77557356e-02\n",
      "   5.87419540e-01 2.32930232e-01 4.61050189e-01 6.44004655e-01\n",
      "   5.37759434e-01 7.23210639e-01 4.54672136e-02 4.06926249e-01\n",
      "   8.20792723e-01 9.03573222e-01 1.28442170e-02 6.58446491e-01]\n",
      "  [5.05588112e-01 3.74679423e-01 5.84278183e-02 3.71558577e-01\n",
      "   7.40630443e-01 8.34117369e-01 1.51099298e-01 6.27628644e-01\n",
      "   7.96042741e-02 4.20482223e-01 1.45880580e-01 3.15920858e-01\n",
      "   3.65174536e-01 4.11052239e-02 7.13820585e-01 9.96618987e-01\n",
      "   8.10794515e-02 6.31313042e-01 8.52390799e-02 8.05958884e-01]\n",
      "  [7.47288001e-01 7.11471582e-01 4.01776377e-01 7.65948235e-01\n",
      "   7.28339670e-01 2.30145736e-01 1.73873980e-01 3.77613697e-01\n",
      "   9.46218481e-01 4.73241985e-01 8.24773429e-01 5.05889614e-01\n",
      "   8.82212214e-01 4.46776894e-01 4.51169208e-01 9.94518360e-01\n",
      "   8.13567294e-01 3.44344636e-01 4.34211116e-01 8.00127115e-01]\n",
      "  [2.62919650e-01 1.10123369e-01 5.05116346e-01 9.71801580e-01\n",
      "   7.59801915e-01 8.41978542e-01 6.30712781e-01 7.49085774e-01\n",
      "   3.48075744e-01 9.66697485e-01 6.45777197e-01 1.14520239e-01\n",
      "   3.73460397e-01 7.25407432e-01 7.93399413e-03 7.37287673e-01\n",
      "   3.02269373e-01 5.33072487e-01 5.08775908e-01 3.18322317e-02]\n",
      "  [2.97231828e-01 3.74465013e-01 9.51571411e-01 3.76871718e-01\n",
      "   2.95367543e-01 9.55345685e-01 7.47411265e-01 7.16018599e-01\n",
      "   3.49541285e-01 5.10820070e-01 4.92680036e-01 6.67928483e-01\n",
      "   4.57537233e-01 1.22132984e-01 8.08390256e-01 4.85804312e-01\n",
      "   8.38189276e-01 9.10930016e-01 1.98137502e-01 2.92486080e-01]\n",
      "  [5.75422107e-01 6.57895758e-01 6.30941177e-01 6.37342074e-01\n",
      "   3.59247912e-02 5.99945317e-01 3.13722589e-01 8.75457895e-01\n",
      "   3.10700192e-01 1.17136522e-01 1.52981667e-01 9.65577423e-01\n",
      "   3.43441922e-01 3.66031532e-01 7.21013746e-01 2.57934330e-01\n",
      "   7.93389117e-01 2.67900165e-01 4.49330970e-01 4.28644410e-01]\n",
      "  [1.41828183e-01 3.58800174e-01 8.28982956e-01 6.96933851e-01\n",
      "   2.47101372e-01 4.95964116e-02 3.12570920e-01 6.47222743e-01\n",
      "   5.77848723e-01 7.47384792e-01 5.75587478e-01 3.29823942e-01\n",
      "   3.77770149e-03 3.30323848e-01 3.98652059e-01 4.54976945e-01\n",
      "   5.78591461e-01 8.10687899e-01 2.59287102e-01 8.97840965e-01]]]\n",
      "---------sess.run(inputs_forward_new)----------\n",
      "[[[[8.96570443e-01]\n",
      "   [8.31685654e-02]\n",
      "   [7.46792569e-01]\n",
      "   [1.06018532e-01]\n",
      "   [7.26397135e-01]\n",
      "   [5.44089672e-01]\n",
      "   [4.82173516e-01]\n",
      "   [9.33843741e-03]\n",
      "   [2.89801706e-01]\n",
      "   [4.10119423e-02]\n",
      "   [9.58390149e-01]\n",
      "   [4.12560511e-01]\n",
      "   [8.83796577e-01]\n",
      "   [1.10268567e-01]\n",
      "   [9.19881510e-01]\n",
      "   [5.78728472e-01]\n",
      "   [5.25630857e-01]\n",
      "   [5.28832557e-01]\n",
      "   [5.56670677e-02]\n",
      "   [1.57373812e-01]]\n",
      "\n",
      "  [[1.04018237e-01]\n",
      "   [4.81320467e-01]\n",
      "   [5.27650978e-01]\n",
      "   [8.57054512e-01]\n",
      "   [7.40748740e-01]\n",
      "   [1.09338858e-01]\n",
      "   [1.00325901e-01]\n",
      "   [1.89790440e-01]\n",
      "   [7.61290041e-02]\n",
      "   [3.29477112e-01]\n",
      "   [4.92564692e-01]\n",
      "   [2.09466067e-01]\n",
      "   [6.62136143e-01]\n",
      "   [4.56833630e-01]\n",
      "   [1.13651210e-01]\n",
      "   [7.64574761e-01]\n",
      "   [8.75553815e-01]\n",
      "   [2.57104266e-01]\n",
      "   [3.82199989e-01]\n",
      "   [8.88400448e-01]]\n",
      "\n",
      "  [[1.92234324e-01]\n",
      "   [7.31839752e-01]\n",
      "   [8.13085637e-01]\n",
      "   [7.11293615e-01]\n",
      "   [9.63730778e-01]\n",
      "   [3.37759737e-01]\n",
      "   [3.34531565e-01]\n",
      "   [8.47761540e-01]\n",
      "   [7.74562021e-02]\n",
      "   [9.49451964e-01]\n",
      "   [9.75115905e-01]\n",
      "   [4.89986068e-01]\n",
      "   [5.10260496e-01]\n",
      "   [9.94694069e-01]\n",
      "   [9.91884385e-01]\n",
      "   [2.85520317e-01]\n",
      "   [5.39394544e-01]\n",
      "   [4.71611336e-01]\n",
      "   [3.33974081e-01]\n",
      "   [7.89076839e-01]]\n",
      "\n",
      "  [[9.92979005e-01]\n",
      "   [2.23866418e-01]\n",
      "   [6.88886401e-01]\n",
      "   [7.62047446e-02]\n",
      "   [6.24134621e-01]\n",
      "   [5.72434206e-01]\n",
      "   [4.08975609e-01]\n",
      "   [8.86981111e-01]\n",
      "   [4.21420820e-01]\n",
      "   [5.99470812e-01]\n",
      "   [9.09434138e-01]\n",
      "   [2.78553699e-01]\n",
      "   [8.17077950e-01]\n",
      "   [3.41340429e-01]\n",
      "   [8.01799717e-02]\n",
      "   [7.70933951e-01]\n",
      "   [9.07635665e-01]\n",
      "   [3.08314716e-01]\n",
      "   [7.67134006e-01]\n",
      "   [7.50601895e-01]]\n",
      "\n",
      "  [[1.18920709e-01]\n",
      "   [9.88059619e-01]\n",
      "   [5.51403647e-03]\n",
      "   [6.17685735e-01]\n",
      "   [1.65720283e-02]\n",
      "   [5.83843144e-02]\n",
      "   [1.09345813e-01]\n",
      "   [7.65406390e-01]\n",
      "   [3.74953736e-01]\n",
      "   [6.57179654e-02]\n",
      "   [7.06696250e-01]\n",
      "   [7.68788786e-01]\n",
      "   [4.46079472e-01]\n",
      "   [2.39773861e-02]\n",
      "   [1.14741026e-01]\n",
      "   [8.85640234e-01]\n",
      "   [9.91610060e-03]\n",
      "   [9.89951930e-01]\n",
      "   [3.87319706e-01]\n",
      "   [1.28302197e-01]]\n",
      "\n",
      "  [[8.35932124e-01]\n",
      "   [6.35716879e-01]\n",
      "   [5.66622421e-01]\n",
      "   [8.60308973e-01]\n",
      "   [5.16702776e-01]\n",
      "   [4.05175870e-01]\n",
      "   [9.75087201e-01]\n",
      "   [7.53946624e-01]\n",
      "   [9.49298331e-01]\n",
      "   [3.32521487e-01]\n",
      "   [4.98948663e-01]\n",
      "   [8.31487158e-01]\n",
      "   [4.14593596e-01]\n",
      "   [1.08733767e-01]\n",
      "   [2.95207571e-01]\n",
      "   [9.63365097e-02]\n",
      "   [2.72041965e-01]\n",
      "   [6.22715275e-01]\n",
      "   [9.63453870e-01]\n",
      "   [3.66451172e-01]]\n",
      "\n",
      "  [[2.67779693e-01]\n",
      "   [5.51881383e-01]\n",
      "   [8.85975484e-01]\n",
      "   [4.39197304e-01]\n",
      "   [2.57868009e-01]\n",
      "   [4.11354695e-01]\n",
      "   [4.27747253e-01]\n",
      "   [8.62450368e-01]\n",
      "   [8.28166561e-01]\n",
      "   [7.46302547e-01]\n",
      "   [7.31208542e-01]\n",
      "   [8.64110317e-01]\n",
      "   [8.72511380e-01]\n",
      "   [1.46454656e-02]\n",
      "   [4.91870336e-01]\n",
      "   [1.63528125e-01]\n",
      "   [3.72650009e-01]\n",
      "   [1.73566381e-01]\n",
      "   [9.21460167e-01]\n",
      "   [9.94657651e-01]]\n",
      "\n",
      "  [[2.57861380e-01]\n",
      "   [5.43326738e-01]\n",
      "   [6.89418629e-01]\n",
      "   [7.44949203e-01]\n",
      "   [5.42144541e-01]\n",
      "   [6.08387495e-01]\n",
      "   [5.95257190e-01]\n",
      "   [1.22885651e-01]\n",
      "   [2.92909080e-01]\n",
      "   [1.93816983e-01]\n",
      "   [7.33291372e-01]\n",
      "   [7.31500145e-01]\n",
      "   [7.18013584e-01]\n",
      "   [8.10905816e-01]\n",
      "   [2.69346513e-01]\n",
      "   [8.22111453e-01]\n",
      "   [6.45305416e-01]\n",
      "   [3.31678287e-01]\n",
      "   [6.96160345e-01]\n",
      "   [8.91131992e-02]]\n",
      "\n",
      "  [[4.43284883e-02]\n",
      "   [3.34382665e-01]\n",
      "   [2.06058600e-01]\n",
      "   [6.40575751e-01]\n",
      "   [6.79700316e-02]\n",
      "   [6.89954568e-01]\n",
      "   [8.38905885e-01]\n",
      "   [7.69455040e-01]\n",
      "   [9.71017231e-01]\n",
      "   [1.08514020e-01]\n",
      "   [5.12066373e-01]\n",
      "   [2.59718081e-01]\n",
      "   [9.47327429e-01]\n",
      "   [1.38100149e-01]\n",
      "   [9.35850832e-01]\n",
      "   [6.75602921e-01]\n",
      "   [6.02855279e-01]\n",
      "   [5.16098812e-01]\n",
      "   [4.64939584e-02]\n",
      "   [6.22011336e-01]]\n",
      "\n",
      "  [[4.44682505e-01]\n",
      "   [5.47630472e-02]\n",
      "   [3.23345770e-01]\n",
      "   [5.96809590e-01]\n",
      "   [8.69848168e-01]\n",
      "   [4.14159401e-01]\n",
      "   [3.70017108e-01]\n",
      "   [7.49865543e-01]\n",
      "   [9.17816042e-02]\n",
      "   [1.66046823e-01]\n",
      "   [1.08873964e-01]\n",
      "   [1.75414634e-01]\n",
      "   [1.56186630e-04]\n",
      "   [9.73711966e-01]\n",
      "   [8.56180380e-01]\n",
      "   [4.83140157e-01]\n",
      "   [8.77924317e-01]\n",
      "   [7.53049506e-01]\n",
      "   [3.18696673e-01]\n",
      "   [9.22830423e-01]]]\n",
      "\n",
      "\n",
      " [[[6.02039320e-01]\n",
      "   [8.00459053e-01]\n",
      "   [1.04356367e-02]\n",
      "   [3.67586269e-01]\n",
      "   [7.93983414e-01]\n",
      "   [3.62995571e-01]\n",
      "   [5.54600497e-01]\n",
      "   [6.12719262e-01]\n",
      "   [2.49250606e-01]\n",
      "   [2.83536497e-01]\n",
      "   [4.13200337e-01]\n",
      "   [2.20946455e-02]\n",
      "   [4.91585011e-01]\n",
      "   [1.04059637e-01]\n",
      "   [3.55707488e-01]\n",
      "   [4.99207265e-03]\n",
      "   [6.70262147e-01]\n",
      "   [1.04029765e-01]\n",
      "   [4.72175832e-01]\n",
      "   [6.86416769e-01]]\n",
      "\n",
      "  [[1.62471963e-01]\n",
      "   [4.16144358e-01]\n",
      "   [6.14523028e-01]\n",
      "   [5.30361593e-01]\n",
      "   [3.83633433e-01]\n",
      "   [2.35939683e-01]\n",
      "   [7.65269774e-01]\n",
      "   [7.35012759e-01]\n",
      "   [2.05205186e-01]\n",
      "   [8.63208518e-01]\n",
      "   [4.89419879e-01]\n",
      "   [8.49441045e-01]\n",
      "   [5.42232207e-01]\n",
      "   [2.09617611e-01]\n",
      "   [2.73755203e-01]\n",
      "   [6.77926415e-02]\n",
      "   [2.08748311e-01]\n",
      "   [8.01157477e-01]\n",
      "   [4.48007974e-01]\n",
      "   [7.38134862e-01]]\n",
      "\n",
      "  [[7.43420553e-01]\n",
      "   [4.76821548e-01]\n",
      "   [8.16741808e-02]\n",
      "   [3.71219574e-01]\n",
      "   [9.68247719e-01]\n",
      "   [3.78425942e-01]\n",
      "   [2.42003800e-01]\n",
      "   [7.39626767e-02]\n",
      "   [3.15392027e-01]\n",
      "   [8.95682986e-01]\n",
      "   [8.55052238e-01]\n",
      "   [6.76803505e-01]\n",
      "   [6.51611320e-01]\n",
      "   [1.93265171e-03]\n",
      "   [3.11154828e-01]\n",
      "   [9.81952709e-01]\n",
      "   [1.80506428e-01]\n",
      "   [1.24686513e-02]\n",
      "   [8.41099856e-01]\n",
      "   [4.62571756e-01]]\n",
      "\n",
      "  [[2.08419546e-01]\n",
      "   [8.57595901e-01]\n",
      "   [3.90342420e-01]\n",
      "   [7.37980996e-01]\n",
      "   [5.87401973e-01]\n",
      "   [6.67498089e-01]\n",
      "   [8.77394254e-01]\n",
      "   [9.77557356e-02]\n",
      "   [5.87419540e-01]\n",
      "   [2.32930232e-01]\n",
      "   [4.61050189e-01]\n",
      "   [6.44004655e-01]\n",
      "   [5.37759434e-01]\n",
      "   [7.23210639e-01]\n",
      "   [4.54672136e-02]\n",
      "   [4.06926249e-01]\n",
      "   [8.20792723e-01]\n",
      "   [9.03573222e-01]\n",
      "   [1.28442170e-02]\n",
      "   [6.58446491e-01]]\n",
      "\n",
      "  [[5.05588112e-01]\n",
      "   [3.74679423e-01]\n",
      "   [5.84278183e-02]\n",
      "   [3.71558577e-01]\n",
      "   [7.40630443e-01]\n",
      "   [8.34117369e-01]\n",
      "   [1.51099298e-01]\n",
      "   [6.27628644e-01]\n",
      "   [7.96042741e-02]\n",
      "   [4.20482223e-01]\n",
      "   [1.45880580e-01]\n",
      "   [3.15920858e-01]\n",
      "   [3.65174536e-01]\n",
      "   [4.11052239e-02]\n",
      "   [7.13820585e-01]\n",
      "   [9.96618987e-01]\n",
      "   [8.10794515e-02]\n",
      "   [6.31313042e-01]\n",
      "   [8.52390799e-02]\n",
      "   [8.05958884e-01]]\n",
      "\n",
      "  [[7.47288001e-01]\n",
      "   [7.11471582e-01]\n",
      "   [4.01776377e-01]\n",
      "   [7.65948235e-01]\n",
      "   [7.28339670e-01]\n",
      "   [2.30145736e-01]\n",
      "   [1.73873980e-01]\n",
      "   [3.77613697e-01]\n",
      "   [9.46218481e-01]\n",
      "   [4.73241985e-01]\n",
      "   [8.24773429e-01]\n",
      "   [5.05889614e-01]\n",
      "   [8.82212214e-01]\n",
      "   [4.46776894e-01]\n",
      "   [4.51169208e-01]\n",
      "   [9.94518360e-01]\n",
      "   [8.13567294e-01]\n",
      "   [3.44344636e-01]\n",
      "   [4.34211116e-01]\n",
      "   [8.00127115e-01]]\n",
      "\n",
      "  [[2.62919650e-01]\n",
      "   [1.10123369e-01]\n",
      "   [5.05116346e-01]\n",
      "   [9.71801580e-01]\n",
      "   [7.59801915e-01]\n",
      "   [8.41978542e-01]\n",
      "   [6.30712781e-01]\n",
      "   [7.49085774e-01]\n",
      "   [3.48075744e-01]\n",
      "   [9.66697485e-01]\n",
      "   [6.45777197e-01]\n",
      "   [1.14520239e-01]\n",
      "   [3.73460397e-01]\n",
      "   [7.25407432e-01]\n",
      "   [7.93399413e-03]\n",
      "   [7.37287673e-01]\n",
      "   [3.02269373e-01]\n",
      "   [5.33072487e-01]\n",
      "   [5.08775908e-01]\n",
      "   [3.18322317e-02]]\n",
      "\n",
      "  [[2.97231828e-01]\n",
      "   [3.74465013e-01]\n",
      "   [9.51571411e-01]\n",
      "   [3.76871718e-01]\n",
      "   [2.95367543e-01]\n",
      "   [9.55345685e-01]\n",
      "   [7.47411265e-01]\n",
      "   [7.16018599e-01]\n",
      "   [3.49541285e-01]\n",
      "   [5.10820070e-01]\n",
      "   [4.92680036e-01]\n",
      "   [6.67928483e-01]\n",
      "   [4.57537233e-01]\n",
      "   [1.22132984e-01]\n",
      "   [8.08390256e-01]\n",
      "   [4.85804312e-01]\n",
      "   [8.38189276e-01]\n",
      "   [9.10930016e-01]\n",
      "   [1.98137502e-01]\n",
      "   [2.92486080e-01]]\n",
      "\n",
      "  [[5.75422107e-01]\n",
      "   [6.57895758e-01]\n",
      "   [6.30941177e-01]\n",
      "   [6.37342074e-01]\n",
      "   [3.59247912e-02]\n",
      "   [5.99945317e-01]\n",
      "   [3.13722589e-01]\n",
      "   [8.75457895e-01]\n",
      "   [3.10700192e-01]\n",
      "   [1.17136522e-01]\n",
      "   [1.52981667e-01]\n",
      "   [9.65577423e-01]\n",
      "   [3.43441922e-01]\n",
      "   [3.66031532e-01]\n",
      "   [7.21013746e-01]\n",
      "   [2.57934330e-01]\n",
      "   [7.93389117e-01]\n",
      "   [2.67900165e-01]\n",
      "   [4.49330970e-01]\n",
      "   [4.28644410e-01]]\n",
      "\n",
      "  [[1.41828183e-01]\n",
      "   [3.58800174e-01]\n",
      "   [8.28982956e-01]\n",
      "   [6.96933851e-01]\n",
      "   [2.47101372e-01]\n",
      "   [4.95964116e-02]\n",
      "   [3.12570920e-01]\n",
      "   [6.47222743e-01]\n",
      "   [5.77848723e-01]\n",
      "   [7.47384792e-01]\n",
      "   [5.75587478e-01]\n",
      "   [3.29823942e-01]\n",
      "   [3.77770149e-03]\n",
      "   [3.30323848e-01]\n",
      "   [3.98652059e-01]\n",
      "   [4.54976945e-01]\n",
      "   [5.78591461e-01]\n",
      "   [8.10687899e-01]\n",
      "   [2.59287102e-01]\n",
      "   [8.97840965e-01]]]]\n",
      "---------sess.run(w)----------\n",
      "[[[[ 0.07966428  0.10579517 -0.02219813  0.0375623  -0.10662986\n",
      "    -0.02860359]]\n",
      "\n",
      "  [[-0.0400072  -0.0423141   0.03406207 -0.09640402  0.04980034\n",
      "    -0.02374825]]\n",
      "\n",
      "  [[-0.06188673  0.08858926 -0.01268581  0.10469646 -0.00668171\n",
      "    -0.01093221]]\n",
      "\n",
      "  [[-0.073405    0.00075048  0.00524278  0.11404208  0.09094592\n",
      "     0.05720773]]\n",
      "\n",
      "  [[ 0.04846669 -0.00328407 -0.00697195 -0.04663285  0.01002032\n",
      "     0.06252485]]\n",
      "\n",
      "  [[-0.00494308 -0.00880233  0.01102623  0.11358363 -0.02639363\n",
      "     0.00732716]]\n",
      "\n",
      "  [[ 0.02827329 -0.07835897 -0.0257834  -0.02611648  0.06693374\n",
      "     0.08878651]]\n",
      "\n",
      "  [[-0.07679258 -0.08341861  0.03117705  0.0709661  -0.08831792\n",
      "     0.10472656]]\n",
      "\n",
      "  [[-0.10923464 -0.00361791 -0.01596512 -0.02714622 -0.06715347\n",
      "     0.01675006]]\n",
      "\n",
      "  [[ 0.09392258 -0.0626716   0.06848788  0.09597207  0.11815958\n",
      "    -0.10817012]]\n",
      "\n",
      "  [[ 0.01043809 -0.02281208 -0.04042909  0.11865904  0.10672355\n",
      "    -0.04635712]]\n",
      "\n",
      "  [[-0.08665104 -0.10233977 -0.0307361  -0.08252102  0.04086574\n",
      "     0.10865339]]\n",
      "\n",
      "  [[-0.09980037  0.10575656 -0.07083174  0.03054673  0.00538498\n",
      "     0.10065433]]\n",
      "\n",
      "  [[ 0.00654646 -0.02186076 -0.05210032  0.11167362  0.06221769\n",
      "    -0.042276  ]]\n",
      "\n",
      "  [[ 0.05827402 -0.04827812 -0.02257029 -0.11235309  0.06806619\n",
      "     0.07331877]]\n",
      "\n",
      "  [[ 0.0035536  -0.1031067   0.11464071 -0.10838869 -0.06227559\n",
      "    -0.10693919]]\n",
      "\n",
      "  [[ 0.04710529 -0.02232573  0.1186287   0.0230075   0.0126371\n",
      "    -0.02009366]]\n",
      "\n",
      "  [[-0.01499388 -0.09047242 -0.01461259  0.11876244  0.02967987\n",
      "    -0.02693239]]\n",
      "\n",
      "  [[-0.09726256 -0.10802986  0.10473975  0.00467887 -0.06179064\n",
      "     0.05383987]]\n",
      "\n",
      "  [[ 0.03647918 -0.09017055  0.05451227  0.01910164 -0.09341052\n",
      "    -0.09016335]]]\n",
      "\n",
      "\n",
      " [[[-0.04034755  0.06286345  0.08869552 -0.06035025 -0.09527387\n",
      "    -0.09086151]]\n",
      "\n",
      "  [[ 0.0843756  -0.02356644  0.10240703  0.07820421  0.00361521\n",
      "    -0.02992734]]\n",
      "\n",
      "  [[ 0.07802892  0.04771719  0.03514225  0.0658818  -0.0907056\n",
      "     0.04692104]]\n",
      "\n",
      "  [[-0.03294833 -0.0838159   0.00831296  0.07313865 -0.04364571\n",
      "    -0.00263353]]\n",
      "\n",
      "  [[ 0.05634799  0.10238423 -0.09573019 -0.08672912 -0.10150614\n",
      "    -0.02638844]]\n",
      "\n",
      "  [[ 0.06554163 -0.10374007 -0.09967681 -0.10294402 -0.00428744\n",
      "    -0.06396495]]\n",
      "\n",
      "  [[ 0.02347776 -0.07548194  0.04252981  0.11167239 -0.08610684\n",
      "     0.0945446 ]]\n",
      "\n",
      "  [[ 0.04353494  0.10512129  0.0468175   0.04937612 -0.04437764\n",
      "    -0.01325864]]\n",
      "\n",
      "  [[-0.07535635 -0.06018817 -0.01233729 -0.11056956  0.05974906\n",
      "    -0.0424056 ]]\n",
      "\n",
      "  [[-0.04287867  0.08260811  0.00101414  0.09524669  0.01011365\n",
      "    -0.02671627]]\n",
      "\n",
      "  [[ 0.0536258  -0.03360336  0.10630377  0.01683087 -0.04057518\n",
      "    -0.01589741]]\n",
      "\n",
      "  [[ 0.10716278  0.11437968 -0.09059641 -0.09444623 -0.07021186\n",
      "    -0.10147112]]\n",
      "\n",
      "  [[ 0.065704   -0.08794729 -0.06501624 -0.10972099  0.07949456\n",
      "    -0.03863306]]\n",
      "\n",
      "  [[ 0.10756005  0.0497651  -0.05510151 -0.08234235 -0.11627324\n",
      "    -0.0710093 ]]\n",
      "\n",
      "  [[ 0.09825803 -0.0201865   0.0163478  -0.04551776 -0.05286603\n",
      "     0.0251833 ]]\n",
      "\n",
      "  [[-0.02301472  0.08646896 -0.00109335  0.08196739  0.00748853\n",
      "    -0.05182046]]\n",
      "\n",
      "  [[ 0.0645565  -0.00767068  0.07638205  0.04505224 -0.01195797\n",
      "    -0.00539803]]\n",
      "\n",
      "  [[-0.09680057 -0.04618027 -0.11181086 -0.11114735 -0.10116652\n",
      "     0.01735809]]\n",
      "\n",
      "  [[ 0.10306104 -0.11941757  0.02132564  0.05386848 -0.04482495\n",
      "     0.05197064]]\n",
      "\n",
      "  [[-0.01582221 -0.08837548  0.04930226  0.04800991  0.05085813\n",
      "     0.01353603]]]\n",
      "\n",
      "\n",
      " [[[-0.00467636 -0.06811833 -0.04739744 -0.09459671  0.10438647\n",
      "     0.11471357]]\n",
      "\n",
      "  [[ 0.11082628 -0.00168206 -0.11475295 -0.11343957  0.00500643\n",
      "     0.11688258]]\n",
      "\n",
      "  [[ 0.0206906  -0.00889663 -0.08951135  0.09135612  0.00319637\n",
      "    -0.02260309]]\n",
      "\n",
      "  [[ 0.04612986 -0.11219724  0.04668435 -0.01330514 -0.08010384\n",
      "     0.0472374 ]]\n",
      "\n",
      "  [[-0.04970016 -0.10805101 -0.09584854 -0.00677866 -0.03612087\n",
      "     0.01105946]]\n",
      "\n",
      "  [[-0.04161217 -0.01460077  0.11729378  0.02945962  0.09933542\n",
      "    -0.09439131]]\n",
      "\n",
      "  [[ 0.08009575  0.00626319  0.0572012   0.00030699 -0.09707218\n",
      "     0.04447336]]\n",
      "\n",
      "  [[-0.04547692  0.01166723  0.07275403  0.02655543 -0.05415937\n",
      "    -0.078182  ]]\n",
      "\n",
      "  [[-0.03707322  0.06531204 -0.01157612 -0.00076468 -0.11465073\n",
      "    -0.03288934]]\n",
      "\n",
      "  [[ 0.03749674  0.11067323  0.04152796 -0.0999846   0.01676633\n",
      "     0.02320462]]\n",
      "\n",
      "  [[-0.08349629  0.04147508 -0.04213291  0.11680619 -0.08940092\n",
      "     0.06971904]]\n",
      "\n",
      "  [[-0.08235326  0.08984285  0.02009066 -0.10425758 -0.05823109\n",
      "     0.08274343]]\n",
      "\n",
      "  [[ 0.05007286  0.03852951 -0.07346316  0.09250613  0.06570084\n",
      "     0.03312825]]\n",
      "\n",
      "  [[-0.0783189   0.0547865  -0.05721182 -0.02063201  0.05166031\n",
      "     0.08951762]]\n",
      "\n",
      "  [[ 0.03789478  0.1111808  -0.11245123 -0.07311596 -0.00371172\n",
      "    -0.03477621]]\n",
      "\n",
      "  [[ 0.07877154 -0.05838967  0.01226496 -0.02996048 -0.02923801\n",
      "     0.06166146]]\n",
      "\n",
      "  [[ 0.10851168  0.10199813  0.05128681  0.05109023  0.031458\n",
      "    -0.08101626]]\n",
      "\n",
      "  [[-0.04631004 -0.09119985  0.04788535  0.02327726 -0.03960021\n",
      "     0.02105374]]\n",
      "\n",
      "  [[-0.06512809 -0.02034032  0.08568931  0.07223294 -0.05045813\n",
      "     0.01528718]]\n",
      "\n",
      "  [[ 0.06229206  0.01116971  0.07810652 -0.00959633  0.00277334\n",
      "    -0.00142422]]]]\n",
      "---------sess.run(conv)----------\n",
      "[[[[15.06219039 12.37101316 16.25787221 13.89105016 14.53962065\n",
      "    16.12657448]]\n",
      "\n",
      "  [[15.99522263 14.95602909 17.94003267 15.46751935 16.68780904\n",
      "    17.3051381 ]]\n",
      "\n",
      "  [[15.28252145 12.53628391 16.76150766 14.80230245 14.79983289\n",
      "    16.97702513]]\n",
      "\n",
      "  [[14.43702721 11.87151188 15.66815623 14.87311634 13.61711138\n",
      "    16.39514837]]\n",
      "\n",
      "  [[15.07873313 13.64117452 16.71704107 15.39708704 14.78610527\n",
      "    17.16754537]]\n",
      "\n",
      "  [[15.70801181 15.35577879 18.21457941 16.83432581 17.35814769\n",
      "    18.57111132]]\n",
      "\n",
      "  [[14.76484052 13.87055698 18.55552614 15.52487729 15.82643864\n",
      "    17.01413063]]\n",
      "\n",
      "  [[15.45108911 12.22262559 17.2635891  14.06858845 14.50925872\n",
      "    16.68675644]]]\n",
      "\n",
      "\n",
      " [[[12.97486602 11.67124574 14.68437357 13.00697276 13.55086289\n",
      "    15.15803639]]\n",
      "\n",
      "  [[14.72109044 13.22799411 16.77320962 15.91491571 14.37157188\n",
      "    16.57913516]]\n",
      "\n",
      "  [[13.47973936 11.59645179 15.91635315 12.36392771 13.727869\n",
      "    15.73464993]]\n",
      "\n",
      "  [[16.24967866 13.58490248 16.17542242 15.66895958 15.24214695\n",
      "    16.57336618]]\n",
      "\n",
      "  [[15.3061882  11.9694974  17.75406133 14.95677575 14.83643331\n",
      "    16.71781806]]\n",
      "\n",
      "  [[15.34026983 14.58573286 18.81621809 16.28903226 16.21406369\n",
      "    19.26362919]]\n",
      "\n",
      "  [[14.96113871 13.92208342 16.76681894 14.6967229  14.44250804\n",
      "    17.5000968 ]]\n",
      "\n",
      "  [[15.18628519 12.06109435 16.3450483  14.44402212 14.38478167\n",
      "    16.29735593]]]]\n",
      "---------sess.run(b)----------\n",
      "[0.39818482 0.63766891 0.783517   0.27916074 0.56128693 0.52825569]\n",
      "---------sess.run(h)----------\n",
      "[[[[15.46037522 13.00868207 17.04138922 14.1702109  15.10090758\n",
      "    16.65483017]]\n",
      "\n",
      "  [[16.39340746 15.593698   18.72354968 15.7466801  17.24909597\n",
      "    17.83339379]]\n",
      "\n",
      "  [[15.68070627 13.17395283 17.54502467 15.08146319 15.36111981\n",
      "    17.50528081]]\n",
      "\n",
      "  [[14.83521203 12.50918079 16.45167323 15.15227708 14.17839831\n",
      "    16.92340406]]\n",
      "\n",
      "  [[15.47691795 14.27884344 17.50055808 15.67624778 15.3473922\n",
      "    17.69580105]]\n",
      "\n",
      "  [[16.10619664 15.9934477  18.99809642 17.11348655 17.91943461\n",
      "    19.099367  ]]\n",
      "\n",
      "  [[15.16302535 14.5082259  19.33904314 15.80403803 16.38772556\n",
      "    17.54238631]]\n",
      "\n",
      "  [[15.84927393 12.8602945  18.0471061  14.34774919 15.07054565\n",
      "    17.21501212]]]\n",
      "\n",
      "\n",
      " [[[13.37305085 12.30891465 15.46789057 13.2861335  14.11214982\n",
      "    15.68629207]]\n",
      "\n",
      "  [[15.11927527 13.86566303 17.55672663 16.19407646 14.93285881\n",
      "    17.10739085]]\n",
      "\n",
      "  [[13.87792418 12.23412071 16.69987015 12.64308845 14.28915593\n",
      "    16.26290561]]\n",
      "\n",
      "  [[16.64786348 14.2225714  16.95893943 15.94812032 15.80343387\n",
      "    17.10162187]]\n",
      "\n",
      "  [[15.70437302 12.60716631 18.53757834 15.23593649 15.39772024\n",
      "    17.24607375]]\n",
      "\n",
      "  [[15.73845465 15.22340178 19.5997351  16.568193   16.77535062\n",
      "    19.79188488]]\n",
      "\n",
      "  [[15.35932354 14.55975233 17.55033595 14.97588364 15.00379497\n",
      "    18.02835249]]\n",
      "\n",
      "  [[15.58447001 12.69876326 17.12856531 14.72318286 14.9460686\n",
      "    16.82561161]]]]\n",
      "---------sess.run(pooled)----------\n",
      "[[[[16.39340746 15.9934477  19.33904314 17.11348655 17.91943461\n",
      "    19.099367  ]]]\n",
      "\n",
      "\n",
      " [[[16.64786348 15.22340178 19.5997351  16.568193   16.77535062\n",
      "    19.79188488]]]]\n"
     ]
    }
   ],
   "source": [
    "word_dim = 10\n",
    "pos_dim = 5\n",
    "hidden_dim = 6\n",
    "sen_len = 10\n",
    "\n",
    "word_embedding = np.random.random([sen_len,10,word_dim])\n",
    "pos_e1_embedding = np.random.random([sen_len,10,pos_dim])\n",
    "pos_e2_embedding = np.random.random([sen_len,10,pos_dim])\n",
    "\n",
    "input_word = [1,3]\n",
    "input_pos_e1 = [1,5]\n",
    "input_pos_e2 = [1,2]\n",
    "\n",
    "inputs_forward = tf.concat(axis=2, values=[tf.nn.embedding_lookup(word_embedding, input_word),\\\n",
    "                                           tf.nn.embedding_lookup(pos_e1_embedding, input_pos_e1), \\\n",
    "                                           tf.nn.embedding_lookup(pos_e2_embedding, input_pos_e2)])\n",
    "\n",
    "inputs_forward_new = tf.Variable(tf.expand_dims(inputs_forward, -1), dtype = np.float64)  #-1表示最后一维\n",
    "\n",
    "window=3\n",
    "filter_data = tf.Variable( np.random.rand(window, word_dim + 2 * pos_dim, 1, hidden_dim), dtype = np.float64)\n",
    "\n",
    "\n",
    "conv = tf.nn.conv2d(\n",
    "    inputs_forward_new,\n",
    "    filter_data,\n",
    "    strides=[1, 1, 1, 1],\n",
    "    padding='VALID',\n",
    "    name='conv')\n",
    "\n",
    "b = tf.Variable( np.random.rand(hidden_dim), dtype = np.float64)\n",
    "h = tf.nn.bias_add(conv, b)\n",
    "\n",
    "pooled = tf.nn.max_pool(\n",
    "        h,\n",
    "        ksize=[1, sen_len - window + 1, 1, 1],\n",
    "        strides=[1, 1, 1, 1],\n",
    "        padding='VALID',\n",
    "        name='pool')\n",
    "\n",
    "with tf.Session() as sess:\n",
    "    sess.run(tf.initialize_all_variables())\n",
    "    print(\"---------sess.run(inputs_forward)----------\")\n",
    "    print(sess.run(inputs_forward))\n",
    "    print(\"---------sess.run(inputs_forward_new)----------\")\n",
    "    print(sess.run(inputs_forward_new))\n",
    "    print(\"---------sess.run(w)----------\")\n",
    "    print(sess.run(w))\n",
    "    print(\"---------sess.run(conv)----------\")\n",
    "    print(sess.run(conv))\n",
    "    print(\"---------sess.run(b)----------\")\n",
    "    print(sess.run(b))\n",
    "    print(\"---------sess.run(h)----------\")\n",
    "    print(sess.run(h))\n",
    "    print(\"---------sess.run(pooled)----------\")\n",
    "    print(sess.run(pooled))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
